﻿<internal:BaseControlPartView x:Class="UColor.WPF.Internal.BaseControlToobarView"
    xmlns:dxdb="clr-namespace:UColor.WPF"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:helpers="clr-namespace:UColor.WPF.Helpers"
    xmlns:ddhelpers="clr-namespace:UColor.Core.Helpers;assembly=UColor.Core"
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    xmlns:dxl="http://schemas.devexpress.com/winfx/2008/xaml/layoutcontrol"
    xmlns:interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:internal="clr-namespace:UColor.WPF.Internal"
    mc:Ignorable="d" 
    d:DesignHeight="173" d:DesignWidth="637">

    <internal:BaseControlPartView.Resources>
        <ddhelpers:BoolInverter x:Key="BoolInverter" />
        <ddhelpers:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
        <ddhelpers:BoolToVisibilityConverter x:Key="BoolToVisibilityInverseConverter" Inverted="True" />
        <ddhelpers:AnyToBooleanConverter x:Key="FlowDirectionConverter">
            <ddhelpers:AnyToBooleanConverter.FalseValue>
                <FlowDirection>LeftToRight</FlowDirection>
            </ddhelpers:AnyToBooleanConverter.FalseValue>
            <ddhelpers:AnyToBooleanConverter.TrueValue>
                <FlowDirection>RightToLeft</FlowDirection>
            </ddhelpers:AnyToBooleanConverter.TrueValue>
        </ddhelpers:AnyToBooleanConverter>

        <ddhelpers:SelectConverter x:Key="ToolbarButtonMouseOverVisiblityConverter">
            <ddhelpers:SelectState Key="False" Value="{ddhelpers:VisibilityValue S=Collapsed}" />
            <ddhelpers:SelectState Key="True" Value="{ddhelpers:VisibilityValue S=Visible}" />
        </ddhelpers:SelectConverter>
        <Style x:Key="ToolbarButtonStyle" TargetType="ButtonBase">
            <Setter Property="ddhelpers:IsMouseOverHelper.EnableIsMouseOver" Value="Enable" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ButtonBase">
                        <Grid Cursor="Hand" x:Name="root">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <DoubleAnimation To="0.5" Storyboard.TargetName="root" Storyboard.TargetProperty="(UIElement.Opacity)" />
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Normal" />
                                    <VisualState x:Name="MouseOver" />
                                    <VisualState x:Name="Pressed">
                                        <Storyboard>
                                            <DoubleAnimation To="0.5" Storyboard.TargetName="root" Storyboard.TargetProperty="(UIElement.Opacity)" />
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="CheckStates">
                                    <VisualState x:Name="Checked">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="hover" Storyboard.TargetProperty="Visibility">
                                                <DiscreteObjectKeyFrame KeyTime="0">
                                                    <DiscreteObjectKeyFrame.Value>
                                                        <Visibility>Visible</Visibility>
                                                    </DiscreteObjectKeyFrame.Value>
                                                </DiscreteObjectKeyFrame>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Unchecked" />
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <StackPanel x:Name="general">
                                <ContentPresenter x:Name="contentPresenter" Content="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}" />
                                <TextBlock x:Name="title" Text="{TemplateBinding Tag}" Foreground="#FF3C3C3C" HorizontalAlignment="Center" />
                            </StackPanel>
                            <StackPanel x:Name="hover" Background="White" Visibility="Collapsed">
                                <Image Source="{Binding Path=(helpers:ForwardingHelper.Content), RelativeSource={RelativeSource TemplatedParent}}" Width="22" Height="22" Stretch="None" HorizontalAlignment="Center" Focusable="False" />
                                <TextBlock x:Name="hoverTitle" Text="{TemplateBinding Tag}" Foreground="#FFFC8127" HorizontalAlignment="Center" />
                            </StackPanel>
                            <StackPanel x:Name="mouseHover" Background="White" Visibility="{ddhelpers:SelectBinding Binding={Binding Path=(ddhelpers:IsMouseOverHelper.IsMouseOver), RelativeSource={RelativeSource TemplatedParent}}, Converter={StaticResource ToolbarButtonMouseOverVisiblityConverter}}">
                                <Image Source="{Binding Path=(helpers:ForwardingHelper.Content), RelativeSource={RelativeSource TemplatedParent}}" Width="22" Height="22" Stretch="None" HorizontalAlignment="Center" Focusable="False" />
                                <TextBlock x:Name="mouseHoverTitle" Text="{TemplateBinding Tag}" Foreground="#FFFC8127" HorizontalAlignment="Center" />
                            </StackPanel>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="dx:FocusHelper2.Focusable" Value="False" />
            <Setter Property="Margin" Value="10,5" />
        </Style>
        <Style x:Key="ToolbarRadioButtonStyle" TargetType="ToggleButton" BasedOn="{StaticResource ToolbarButtonStyle}">
            <Setter Property="IsHitTestVisible" Value="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={StaticResource BoolInverter}}" />
        </Style>
        <Style x:Key="ToolbarSeparatorStyle" TargetType="Border">
            <Setter Property="Margin" Value="10,5" />
            <Setter Property="BorderBrush" Value="#d9d9d9" />
            <Setter Property="BorderThickness" Value="1" />
            <Setter Property="Width" Value="1" />
        </Style>
    </internal:BaseControlPartView.Resources>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="50" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <TextBlock HorizontalAlignment="Left" FontFamily="Segoe UI Light, Tahoma Light" FontSize="31" Foreground="#FF3C3C3C" helpers:TextTrimmingHelper.TextTrimming="CharacterEllipsis" Text="{Binding Title.TextAsync}" />
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Column="2" Margin="0,3,0,-3">
            <Button Style="{StaticResource ToolbarButtonStyle}" Command="{Binding RequestPrevDemoCommand}" Tag="后退" helpers:ForwardingHelper.Content="/UColor.APP;component/Images/ToolbarItems/PrevSelected.png">
                <Image Source="/UColor.APP;component/Images/ToolbarItems/Prev.png" Stretch="None" HorizontalAlignment="Center" Focusable="False" Width="22" Height="22" />
            </Button>
            <Button Style="{StaticResource ToolbarButtonStyle}" Command="{Binding RequestNextDemoCommand}" Tag="前进" helpers:ForwardingHelper.Content="/UColor.APP;component/Images/ToolbarItems/NextSelected.png">
                <Image Source="/UColor.APP;component/Images/ToolbarItems/Next.png" Stretch="None" HorizontalAlignment="Center" Focusable="False"  Width="22" Height="22"/>
            </Button>
            <ToggleButton x:Name="RTLButton" Style="{StaticResource ToolbarButtonStyle}" IsChecked="{Binding DemoFlowDirection, Mode=TwoWay, Converter={StaticResource FlowDirectionConverter}}" Tag="购物车" helpers:ForwardingHelper.Content="/UColor.APP;component/Images/ToolbarItems/FlowDirectionSelected.png"
                IsEnabled="True">
                <Image Source="/UColor.APP;component/Images/ToolbarItems/FlowDirection.png" Stretch="None" HorizontalAlignment="Center" Focusable="False"  Width="22" Height="22" />
            </ToggleButton>
            <Border Style="{StaticResource ToolbarSeparatorStyle}" />
            <ToggleButton x:Name="DemoButton" Style="{StaticResource ToolbarRadioButtonStyle}" IsChecked="{Binding DemoButtonIsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Tag="更新" helpers:ForwardingHelper.Content="/UColor.APP;component/Images/ToolbarItems/DemoSelected.png">
                <Image Source="/UColor.APP;component/Images/ToolbarItems/Demo.png" Stretch="None" HorizontalAlignment="Center" Focusable="False" Width="22" Height="22"  />
            </ToggleButton>
            <ToggleButton x:Name="CSCodeButton" Style="{StaticResource ToolbarRadioButtonStyle}" IsChecked="{Binding CSCodeButtonIsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Tag="上传文档" helpers:ForwardingHelper.Content="/UColor.APP;component/Images/ToolbarItems/CodeSelected.png">
                <Image Source="/UColor.APP;component/Images/ToolbarItems/Code.png" Stretch="None" HorizontalAlignment="Center" Focusable="False"  Width="22" Height="22" />
            </ToggleButton>
            <ToggleButton x:Name="VBCodeButton" Style="{StaticResource ToolbarRadioButtonStyle}" IsChecked="{Binding VBCodeButtonIsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Tag="设计" helpers:ForwardingHelper.Content="/UColor.APP;component/Images/ToolbarItems/CodeSelected.png">
                <Image Source="/UColor.APP;component/Images/ToolbarItems/Code.png" Stretch="None" HorizontalAlignment="Center" Focusable="False"  Width="22" Height="22" />
            </ToggleButton>
            <ToggleButton x:Name="XamlButton" Style="{StaticResource ToolbarRadioButtonStyle}" IsChecked="{Binding XamlButtonIsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Tag="查询" helpers:ForwardingHelper.Content="/UColor.APP;component/Images/ToolbarItems/CodeSelected.png">
                <Image Source="/UColor.APP;component/Images/ToolbarItems/Code.png" Stretch="None" HorizontalAlignment="Center" Focusable="False"  Width="22" Height="22" />
            </ToggleButton>
            <Border Style="{StaticResource ToolbarSeparatorStyle}" />
            <ToggleButton x:Name="OptionsButton" Style="{StaticResource ToolbarButtonStyle}" IsEnabled="{Binding HasOptions}" IsChecked="{Binding OptionsButtonIsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Tag="选项" helpers:ForwardingHelper.Content="/UColor.APP;component/Images/ToolbarItems/OptionsSelected.png">
                <Image Source="/UColor.APP;component/Images/ToolbarItems/Options.png" Stretch="None" HorizontalAlignment="Center" Focusable="False"  Width="22" Height="22" />
            </ToggleButton>
            <ToggleButton x:Name="ThemesButton" Style="{StaticResource ToolbarButtonStyle}" IsEnabled="{Binding AllowThemes}" IsChecked="{Binding ThemesButtonIsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Tag="主题" helpers:ForwardingHelper.Content="/UColor.APP;component/Images/ToolbarItems/ThemesSelected.png">
                <Image Source="/UColor.APP;component/Images/ToolbarItems/Themes.png" Stretch="None" HorizontalAlignment="Center" Focusable="False"  Width="22" Height="22" />
            </ToggleButton>
            <ToggleButton x:Name="SidebarButton" Style="{StaticResource ToolbarButtonStyle}" IsChecked="{Binding SidebarButtonIsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Visibility="{Binding SidebarVisibility}" Tag="{Binding SidebarTag}" helpers:ForwardingHelper.Content="{Binding SidebarIconSelected}">
                <Image Source="{Binding SidebarIcon}" Stretch="None" HorizontalAlignment="Center" Focusable="False"  Width="22" Height="22" />
            </ToggleButton>
            <ToggleButton x:Name="AboutButton" Style="{StaticResource ToolbarButtonStyle}" IsChecked="{Binding AboutButtonIsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Tag="关于" helpers:ForwardingHelper.Content="/UColor.APP;component/Images/ToolbarItems/AboutSelected.png">
                <Image Source="/UColor.APP;component/Images/ToolbarItems/About.png" Stretch="None" HorizontalAlignment="Center" Focusable="False"  Width="22" Height="22" />
            </ToggleButton>
        </StackPanel>
    </Grid>
</internal:BaseControlPartView>